package com.springboot.ww.controller;

import com.springboot.ww.dto.Condition;
import com.springboot.ww.dto.Query;
import com.springboot.ww.entity.PackageHis;
import com.springboot.ww.entity.PackageMain;
import com.springboot.ww.mapper.PackageHisMapper;
import com.springboot.ww.mapper2.PackageHisMapper2;
import com.springboot.ww.mapper2.PackageMainMapper2;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2025-07-04 11:39
 */
@AllArgsConstructor
@RestController
@RequestMapping("/dynamic")
public class TestController {

    private final PackageHisMapper packageHisMapper;
    private final PackageHisMapper2 packageHisMapper2;
    private final PackageMainMapper2 packageMainMapper2;


    @GetMapping("/test")
    @Transactional
    public R<String> test(Query query, String packageCode) {
        List<PackageHis> packageHis = packageHisMapper.selectPackageHisPage(Condition.getPage(query), packageCode, null);
        System.out.println(JsonUtil.toJson(packageHis));
        List<PackageHis> packageHis2 = packageHisMapper.selectPackageHisPage(Condition.getPage(query), packageCode, null);
        System.out.println(JsonUtil.toJson(packageHis2));
        return R.data("测试成功");
    }

    @GetMapping("/test2")
    public R<String> test2(Query query, String packageCode) {
        List<PackageHis> packageHis = packageHisMapper2.selectPackageHisPage(Condition.getPage(query), packageCode, null);
        System.out.println(JsonUtil.toJson(packageHis));
        return R.data("测试成功");
    }

    @GetMapping("/test3")
    public R<String> test3(String packageCode) {
        PackageMain main = packageMainMapper2.getByPackageCode(packageCode);
        System.out.println(JsonUtil.toJson(main));
        return R.data("测试成功");
    }
}
